import { createRouter, createWebHashHistory } from 'vue-router';
import type { RouteRecordRaw } from 'vue-router';
import menuRouter from './menuRouter';
import systemRouter from './systemRouter';
// import Layout from '@/layout/index.vue';

/* 要写了meta导航菜单才会有，若只有单个路由且有chidren，meta必须写在children中导航菜单才有 */
// 用来动态添加
export const asyncRoutes: RouteRecordRaw[] = [
	// 404 page must be placed at the end !!!
	menuRouter,
	systemRouter,
];

// 基本路由
export const constantRoutes: Array<RouteRecordRaw> = [
	{
		path: '/',
		redirect: '/menu/overView',
		meta: { hidden: true },
	},
	{
		path: '/login',
		meta: { hidden: true },
		children: [
			{
				path: '/login',
				name: 'login',
				meta: { hidden: true },
				component: () => import('@/views/login/index.vue'),
			},
		],
	},
	{
		path: '/:pathMatch(.*)*',
		component: () => import('@/views/404.vue'),
		meta: { hidden: true },
	},
];

const router = createRouter({
	history: createWebHashHistory(),
	routes: constantRoutes,
});

export default router;
